package com.hzit.search.controller;

import com.hzit.search.service.ItemSearchService;
import com.hzit.search.vo.ItemVo;
import org.elasticsearch.search.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.Map;

/**
 * 类名：
 * 作者：WF
 * 功能：
 */
@Controller
public class SearchController {

	@Autowired
	private ItemSearchService searchService;

	@GetMapping({"/","/search.html"})
	public String search(ItemVo vo, Model model) throws IOException {
		Map<String,Object> map = searchService.search(vo);
		model.addAttribute("resultMap",map);
		model.addAttribute("vo",vo);
		return "search";
	}
}
